package com.wl.mall.web.search.controller;

import com.wl.mall.search.feign.SkuSearchFeign;
import com.wl.mall.util.common.entity.RespResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@Controller
@RequestMapping(value = "/web/search")
public class SearchController {

    @Autowired
    private SkuSearchFeign skuSearchFeign;
    /****
     * 搜索页面跳转
     * @return
     */
    @GetMapping
    public String search(Model model, @RequestParam Map<String,Object> searchParam){
        RespResult<Map<String, Object>> search = skuSearchFeign.search(searchParam);
        model.addAttribute("result",search.getData());
        model.addAttribute("searchMap",search);
        return "search";
    }
}